package jgcp.config;

import java.io.IOException;
import java.util.Properties;
/**
 * 
 * @Date 28/05/2009
 * @author Jie Zhao (288654)
 * @version 1.0
 */
public class Configuration {
	private static Configuration instance = new Configuration();
	private Properties prop = new Properties();
	
	private Configuration()
	{
		try {
			prop.load(this.getClass().getResourceAsStream("config.prop"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	public boolean checkusername(String username)
	{
		return prop.containsKey(username);
	}
	public static Configuration getInstance()
	{
		return instance;
	}
	
	public int getServerPort()
	{
		return Integer.parseInt(prop.getProperty("serverPort", "1234"));
	}
	public int getMasterPort()
	{
		return Integer.parseInt(prop.getProperty("masterPort","2345"));
	}
	public int getHeartbeatInterval()
	{
		return Integer.parseInt(prop.getProperty("HeartbeatInterval", "5000"));
	}
	public String getMasterTempfolder()
	{
		return prop.getProperty("master.tempfolder","d:/temp/master/");
	}
	public String getClientTempfolder()
	{
		return prop.getProperty("client.tempfolder","d:/temp/client/");
	}
	public String getWorkerTempfolder()
	{
		return prop.getProperty("worker.tempfolder","d:/temp/worker/");
	}
	
	public String getJavahome()
	{
		return prop.getProperty("javahome");
	}
//	/*
//	 * Added by Dongwei Qi.
//	 */
//	public String getStartFlag(){
//		return prop.getProperty("start");
//	}
//	
//	/*
//	 * Added by Dongwei Qi.
//	 */
//	public void setStartFlag(String start){
//		prop.setProperty("start", start);
//	}
//	
//	public int getJFlag(){
//		return Integer.parseInt(prop.getProperty("j_1"));
//	}
//	
//	public void setJFlag(String j_1){
//		prop.setProperty("j_1", j_1);
//	}
}
